<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>addMinutesToDate</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const addMinutesToDate = (date, n) => {
            const d = new Date(date);
            d.setTime(d.getTime() + n * 60000);
            return d.toISOString().split('.')[0].replace('T', ' ');
        };
        console.log(addMinutesToDate('2020-10-19 12:00:00', 10)); // '2020-10-19 12:10:00'
        console.log(addMinutesToDate('2020-10-19', -10)); // '2020-10-18 23:50:00'
    </script>
</body>

</html>